﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.General;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service
{
    public class SolutionPageContentService : IService<SolutionPageContent>
    {
        private readonly GenericRepository<SolutionPageContent> _solutionPageContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public SolutionPageContentService(IUnitOfWork unitOfWork, GenericRepository<SolutionPageContent> solutionPageContentRepository)
        {
            this._solutionPageContentRepository = solutionPageContentRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<SolutionPageContent> GetAllElements()
        {
            return _solutionPageContentRepository.GetAll();
        }

        public SolutionPageContent GetElementById(int id)
        {
            return _solutionPageContentRepository.GetById(id);
        }

        public void CreateElement(SolutionPageContent entity)
        {
            _solutionPageContentRepository.Insert(entity);
        }

        public void UpdateElement(SolutionPageContent entity)
        {
            _solutionPageContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _solutionPageContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
